/*
	Cash_check
	
		Filter out cash withdrawals and check payments using 
		transaction descriptions.
		
	Lorenz Kueng
*/

*----------------------------------------------------
* Infer Cash Spending
*----------------------------------------------------


	cap drop description
	generate description = lower(genericXXXXdescription)
	
	cap drop cash
	generate cash = regexm(description, "atm withdrawal") | ///
					regexm(description, "atm withdrwl")   | ///
					regexm(description, "withdrawal atm") | ///
					regexm(description, "withdrwl atm")   | ///
					regexm(description, "cash withdrawal")| ///
					regexm(description, "cash withdrwl")  | ///
					regexm(description, "withdrawal cash")| ///
					regexm(description, "withdrwl cash")  | ///
					description=="withdrawal" | description=="withdrwl" ///
	
	replace inferredcategoryid = 2001 if cash==1 
	
	drop cash
	

*----------------------------------------------------
* Infer Check deposits (TO BE IMPROVED!!!!)
*----------------------------------------------------


/*
	cap drop description
	generate description = lower(genericXXXXdescription)
	
	cap drop check
	generate check =regexm(description, "check ") | ///
					regexm(description, " check")  //
					
	foreach string in checking checkin transfer checkout healthcheck toothcheck marcheck cafecheck {
		
		display "`string'"
		cap drop `string'
		generate `string' = regexm(description, "`string'")
		replace check =0 if `string'==1
		drop `string'
	}
	
	replace check = 0 if description=="background checks"|description==
		
	replace inferredcategoryid = 2002 if check==1 
	
	drop check 
*/	
					
	

	drop description

